package com.example.simpleforum.model;

import java.sql.Timestamp;

/**
 * 回复实体类
 */
public class Reply {
    private int id;             // 回复ID，主键
    private String content;     // 回复内容
    private int userId;         // 回复用户ID，外键
    private int postId;         // 所属帖子ID，外键
    private Timestamp createTime; // 回复时间
    private Timestamp updateTime; // 更新时间
    
    // 非数据库字段，用于展示
    private String username;    // 回复用户名

    // 构造函数
    public Reply() {
    }

    public Reply(String content, int userId, int postId) {
        this.content = content;
        this.userId = userId;
        this.postId = postId;
        this.createTime = new Timestamp(System.currentTimeMillis());
        this.updateTime = this.createTime;
    }

    public Reply(int id, String content, int userId, int postId, Timestamp createTime, Timestamp updateTime) {
        this.id = id;
        this.content = content;
        this.userId = userId;
        this.postId = postId;
        this.createTime = createTime;
        this.updateTime = updateTime;
    }

    // Getter和Setter方法
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public int getPostId() {
        return postId;
    }

    public void setPostId(int postId) {
        this.postId = postId;
    }

    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    public Timestamp getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Timestamp updateTime) {
        this.updateTime = updateTime;
    }
    
    public String getUsername() {
        return username;
    }
    
    public void setUsername(String username) {
        this.username = username;
    }

    @Override
    public String toString() {
        return "Reply{" +
                "id=" + id +
                ", content='" + content + '\'' +
                ", userId=" + userId +
                ", postId=" + postId +
                ", username='" + username + '\'' +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                '}';
    }
}